/**
 * Copyright [2019] [LiBo/Alex of copyright liboware@gmail.com ]
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hyts.fileupload.domain;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.InputStream;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @project-name:coffice-toolbox
 * @package-name:com.hyts.fileupload.domain
 * @author:LiBo/Alex
 * @create-date:2020-05-07 11:24
 * @copyright:libo-alex4java
 * @email:liboware@gmail.com
 * @description:
 */
@SuppressWarnings("serial")
@Entity
@Data
@NoArgsConstructor
@Table(name="TBL_FILE_INFO")
public class FileInfoDomain extends BaseDomain{

    /**
     * 文件资源ID ，绑定业务来源的ID
     */
    @NonNull
    @Column(name = "resource_id")
    private String resourceId;

    /**
     * 上传后的文件名
     */
    @NonNull
    @Column(name = "file_name")
    private String fileName;

    /**
     * 原文件名
     */
    @NonNull
    @Column(name = "file_origin_name")
    private String fileOriginName;

    /**
     * 文件路径
     */
    @JsonIgnore
    @Column(name = "file_path")
    private String filePath;

    /**
     * md5编码压缩编码存储
     */
    @Column(name = "md5")
    private String md5;

    /**
     * 文件类型
     */
    @JsonIgnore
    @Column(name = "file_type")
    private String fileType;

    /**
     * 文件大小字节大小
     */
    @Column(nullable = false, name = "size")
    private Long size;

    /**
     * 文件是否后效 true/1: 有效 ; false/0 : 无效
     */
    @JsonIgnore
    @Column(length = 2, name = "valid")
    private Boolean valid = true;

    /**
     *  是否删除文件
     */
    @JsonIgnore
    @Column(length = 2, name = "is_delete")
    private Boolean isDelete = false;

    /**
     * 图片上传时间
     */
    @NonNull
    @Column(name = "upload_time")
    private String uploadTime = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));

    /**
     * 图片删除时间
     */
    @NonNull
    @Column(name = "delete_time")
    private String deleteTime;

    /**
     * 文件信息内容数据
     */
    @JSONField(serialize = false)
    @Transient
    private InputStream content;

}
